﻿namespace WMS6.Web
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Web;
    using WMS6.Web.CrossdockServiceRef;

    public class CrossdockServiceClientProxy : BasePage
    {
        public string DeleteApportionRuleInfo(List<string> OwnerIDs, List<string> CustomerIDs, List<string> SeqNo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.DeleteApportionRuleInfo(OwnerIDs, CustomerIDs, SeqNo, pubParasInfo);
            }
        }

        public string DeleteLaneInfo(List<string> laneInfoIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.DeleteLaneInfo(laneInfoIDs, pubParasInfo);
            }
        }

        public string DeleteOppOrderRuleDetailInfo(List<string> opporderRuleIDs, List<string> lineIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.DeleteOppOrderRuleDetailInfo(opporderRuleIDs, lineIDs, pubParasInfo);
            }
        }

        public string DeleteOppOrderRuleInfo(List<string> OppOrderRuleIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.DeleteOppOrderRuleInfo(OppOrderRuleIDs, pubParasInfo);
            }
        }

        public DataSet GetAllApportionRuleInfo()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.GetAllApportionRuleInfo(pubParasInfo);
            }
        }

        public DataSet GetAllLaneInfo()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.GetAllLaneInfo(pubParasInfo);
            }
        }

        public DataSet GetAllOpporderRuleDetail()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.GetAllOpporderRuleDetail(pubParasInfo);
            }
        }

        public DataSet GetAllOppOrderRuleInfo()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.GetAllOppOrderRuleInfo(pubParasInfo);
            }
        }

        public ApportionRuleInfo GetApportionRuleInfoByID(string OwnerID, string CustomerID, string SeqNo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.GetApportionRuleInfoByID(OwnerID, CustomerID, SeqNo, pubParasInfo);
            }
        }

        public DataSet GetApportionRuleInfoByQueryEntity(ApportionRuleQueryEntity apportionRuleQuery)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.GetApportionRuleInfoByQueryEntity(apportionRuleQuery, pubParasInfo);
            }
        }

        public List<ApportionRuleInfo> GetApportionRuleListByID(string OwnerID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.GetApportionRuleListByID(OwnerID, pubParasInfo);
            }
        }

        public static CrossdockServiceClientProxy GetInstance()
        {
            return new CrossdockServiceClientProxy();
        }

        public LaneInfo GetLaneInfoByID(string laneID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.GetLaneInfoByID(laneID, pubParasInfo);
            }
        }

        public DataSet GetLaneInfoByQueryEntity(LaneQueryEntity laneQuery)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.GetLaneInfoByQueryEntity(laneQuery, pubParasInfo);
            }
        }

        public DataSet GetOppOrderRuleDetailByQueryEntity(OppOrderRuleDetailQueryEntity oppOrderRuleDetailQuery)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.GetOppOrderRuleDetailByQueryEntity(oppOrderRuleDetailQuery, pubParasInfo);
            }
        }

        public OppOrderRuleDetailInfo GetOppOrderRuleDetailInfoByID(string opporderRuleID, string lineID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.GetOppOrderRuleDetailInfoByID(opporderRuleID, lineID, pubParasInfo);
            }
        }

        public List<OppOrderRuleDetailInfo> GetOpporderRuleDetailListByID(string opporderRuleID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.GetOpporderRuleDetailListByID(opporderRuleID, pubParasInfo);
            }
        }

        public OppOrderRuleInfo GetOppOrderRuleIDByID(string opporderRuleID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.GetOppOrderRuleIDByID(opporderRuleID, pubParasInfo);
            }
        }

        public DataSet GetOppOrderRuleInfoByQueryEntity(OppOrderRuleQueryEntity oppOrderRuleQuery)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.GetOppOrderRuleInfoByQueryEntity(oppOrderRuleQuery, pubParasInfo);
            }
        }

        private PubParasInfo InitPubParasInfo()
        {
            if (base.UserInfo != null)
            {
                return new PubParasInfo { UserID = base.UserInfo.UserID, UserLanguage = base.UserInfo.Preference.Lang, CurrentWH = base.UserInfo.CurrentWH };
            }
            HttpContext.Current.Response.Redirect("../Login.aspx?from=Logout", true);
            return null;
        }

        public string InsertApportionRuleInfo(ApportionRuleInfo apportionRuleInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.InsertApportionRuleInfo(apportionRuleInfo, pubParasInfo);
            }
        }

        public string InsertLaneInfo(LaneInfo laneInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.InsertLane(laneInfo, pubParasInfo);
            }
        }

        public string InsertOppOrderRuleDetailInfo(OppOrderRuleDetailInfo oppOrderRuleDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.InsertOppOrderRuleDetailInfo(oppOrderRuleDetailInfo, pubParasInfo);
            }
        }

        public string InsertOppOrderRuleInfo(OppOrderRuleInfo oppOrderRuleInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.InsertOppOrderRuleInfo(oppOrderRuleInfo, pubParasInfo);
            }
        }

        public string UpdateApportionRuleInfo(ApportionRuleInfo apportionRuleInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.UpdateApportionRuleInfo(apportionRuleInfo, pubParasInfo);
            }
        }

        public string UpdateLaneInfo(LaneInfo laneInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.UpdateLane(laneInfo, pubParasInfo);
            }
        }

        public string UpdateOppOrderRuleDetailInfo(OppOrderRuleDetailInfo oppOrderRuleDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.UpdateOppOrderRuleDetailInfo(oppOrderRuleDetailInfo, pubParasInfo);
            }
        }

        public string UpdateOppOrderRuleInfo(OppOrderRuleInfo oppOrderRuleInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (CrossdockServiceClient client = new CrossdockServiceClient("WSHttpBinding_ICrossdockService"))
            {
                return client.UpdateOppOrderRuleInfo(oppOrderRuleInfo, pubParasInfo);
            }
        }
    }
}

